package com.search.dynamics.samples.spring.controller;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.criterion.Expression;

import com.search.dynamics.samples.spring.dao.Hotels;
import com.search.dynamics.samples.spring.dao.SDSessionFactory;

public class DWRRequestHandler {

	@SuppressWarnings("unchecked")
	public Hotels getHotelDetails(int hotelId) {
		Hotels hotel=null;
		try {
			Session conn =  SDSessionFactory.getInstance().openSession();
			List<Hotels> hotels=conn.createCriteria(Hotels.class).add(Expression.eq("hotel_id", hotelId)).list();
			if(hotels != null) {
				hotel=hotels.get(0);
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return hotel;
	}

}
